package cn.byapps.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;

@Entity(name = "UploadFile")
public class UploadFile {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	@Column(length = 64)
	private String id;// 文件唯一id,uuid
	@Column(length = 100)
	private String fileName;// 文件上传名称
	@Column(length = 150)
	private String filePath;// 文件保存路径
	@Temporal(TemporalType.TIMESTAMP)
	private Date fileDate = new Date();// 上传时间
	@Column(scale = 2) // 两位小数点
	private Double size;// 文件大小
	@Lob
	private String remark;

	@Column(length = 250)
	private String title;

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@ManyToOne
	@JoinColumn(name = "userId")
	private User user;

	public UploadFile(String title, String remark, String fileName, String filePath, Double size, User user) {
		super();
		this.title = title;
		this.remark = remark;
		this.fileName = fileName;
		this.filePath = filePath;
		this.size = size;
		this.user = user;
	}

	public UploadFile() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Double getSize() {
		return size;
	}

	public void setSize(Double size) {
		this.size = size;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	public Date getFileDate() {
		return fileDate;
	}

	public void setFileDate(Date fileDate) {
		this.fileDate = fileDate;
	}
}
